#ifndef _MODBUS_H_
#define _MODBUS_H_

#include "main.h"

#define modbus_size 0x500//modbus寄存器数组大小

#define modbus_flash_write_flag 0x400//flash写入标记位，当等于0x10时flash写入失败


 #define modbus_sensor_time_year_version 0xF9//出厂时间-年
 #define modbus_sensor_time_mn_version 0xFA//出厂时间-月日，1201（12月1日），901（9月1日）

 #define modbus_sensor_hardware_version 0xFB//硬件版本
 #define modbus_sensor_software_version 0xFC//软件版本

#define modbus_devid 0xFF//设备地址

extern uint16_t modbus_protocol[modbus_size];
/*----------------------------------------------------*/
// 各串口读取通道数量配置
#define modbus_Usart2_ReadChannel_Times 0x00
#define modbus_Usart3_ReadChannel_Times 0x01
#define modbus_Uart4_ReadChannel_Times 0x02
#define modbus_Uart5_ReadChannel_Times 0x03
#define modbus_Usart6_ReadChannel_Times 0x04
#define modbus_Uart7_ReadChannel_Times 0x05
#define modbus_Uart8_ReadChannel_Times 0x06
#define modbus_Uart9_ReadChannel_Times 0x07
#define modbus_Usart10_ReadChannel_Times 0x08
/*----------------------------------------------------*/
// 串口波特率配置
#define modbus_sensor_Usart1_Boudrate 0x11 
#define modbus_sensor_Usart2_Boudrate 0x12 
#define modbus_sensor_Usart3_Boudrate 0x13 
#define modbus_sensor_Uart4_Boudrate 0x14 
#define modbus_sensor_Uart5_Boudrate 0x15 
#define modbus_sensor_Usart6_Boudrate 0x16 
#define modbus_sensor_Uart7_Boudrate 0x17 
#define modbus_sensor_Uart8_Boudrate 0x18 
#define modbus_sensor_Uart9_Boudrate 0x19 
#define modbus_sensor_Usart10_Boudrate 0x1A

// 串口2采集的数据类型
#define modbus_sensor_Usart2_CH1_datatype 0x21
#define modbus_sensor_Usart2_CH2_datatype 0x22
#define modbus_sensor_Usart2_CH3_datatype 0x23
#define modbus_sensor_Usart2_CH4_datatype 0x24
#define modbus_sensor_Usart2_CH5_datatype 0x25
#define modbus_sensor_Usart2_CH6_datatype 0x26
#define modbus_sensor_Usart2_CH7_datatype 0x27
#define modbus_sensor_Usart2_CH8_datatype 0x28
#define modbus_sensor_Usart2_CH9_datatype 0x29
#define modbus_sensor_Usart2_CH10_datatype 0x2A

// 串口3采集的数据类型
#define modbus_sensor_Usart3_CH1_datatype 0x31
#define modbus_sensor_Usart3_CH2_datatype 0x32
#define modbus_sensor_Usart3_CH3_datatype 0x33
#define modbus_sensor_Usart3_CH4_datatype 0x34
#define modbus_sensor_Usart3_CH5_datatype 0x35
#define modbus_sensor_Usart3_CH6_datatype 0x36
#define modbus_sensor_Usart3_CH7_datatype 0x37
#define modbus_sensor_Usart3_CH8_datatype 0x38
#define modbus_sensor_Usart3_CH9_datatype 0x39
#define modbus_sensor_Usart3_CH10_datatype 0x3A

// 串口4采集的数据类型
#define modbus_sensor_Uart4_CH1_datatype 0x41
#define modbus_sensor_Uart4_CH2_datatype 0x42
#define modbus_sensor_Uart4_CH3_datatype 0x43
#define modbus_sensor_Uart4_CH4_datatype 0x44
#define modbus_sensor_Uart4_CH5_datatype 0x45
#define modbus_sensor_Uart4_CH6_datatype 0x46
#define modbus_sensor_Uart4_CH7_datatype 0x47
#define modbus_sensor_Uart4_CH8_datatype 0x48
#define modbus_sensor_Uart4_CH9_datatype 0x49
#define modbus_sensor_Uart4_CH10_datatype 0x4A

// 串口5采集的数据类型
#define modbus_sensor_Uart5_CH1_datatype 0x51
#define modbus_sensor_Uart5_CH2_datatype 0x52
#define modbus_sensor_Uart5_CH3_datatype 0x53
#define modbus_sensor_Uart5_CH4_datatype 0x54
#define modbus_sensor_Uart5_CH5_datatype 0x55
#define modbus_sensor_Uart5_CH6_datatype 0x56
#define modbus_sensor_Uart5_CH7_datatype 0x57
#define modbus_sensor_Uart5_CH8_datatype 0x58
#define modbus_sensor_Uart5_CH9_datatype 0x59
#define modbus_sensor_Uart5_CH10_datatype 0x5A

// 串口6采集的数据类型
#define modbus_sensor_Usart6_CH1_datatype 0x61
#define modbus_sensor_Usart6_CH2_datatype 0x62
#define modbus_sensor_Usart6_CH3_datatype 0x63
#define modbus_sensor_Usart6_CH4_datatype 0x64
#define modbus_sensor_Usart6_CH5_datatype 0x65
#define modbus_sensor_Usart6_CH6_datatype 0x66
#define modbus_sensor_Usart6_CH7_datatype 0x67
#define modbus_sensor_Usart6_CH8_datatype 0x68
#define modbus_sensor_Usart6_CH9_datatype 0x69
#define modbus_sensor_Usart6_CH10_datatype 0x6A

// 串口7采集的数据类型
#define modbus_sensor_Uart7_CH1_datatype 0x71
#define modbus_sensor_Uart7_CH2_datatype 0x72
#define modbus_sensor_Uart7_CH3_datatype 0x73
#define modbus_sensor_Uart7_CH4_datatype 0x74
#define modbus_sensor_Uart7_CH5_datatype 0x75
#define modbus_sensor_Uart7_CH6_datatype 0x76
#define modbus_sensor_Uart7_CH7_datatype 0x77
#define modbus_sensor_Uart7_CH8_datatype 0x78
#define modbus_sensor_Uart7_CH9_datatype 0x79
#define modbus_sensor_Uart7_CH10_datatype 0x7A

// 串口8采集的数据类型
#define modbus_sensor_Uart8_CH1_datatype 0x81
#define modbus_sensor_Uart8_CH2_datatype 0x82
#define modbus_sensor_Uart8_CH3_datatype 0x83
#define modbus_sensor_Uart8_CH4_datatype 0x84
#define modbus_sensor_Uart8_CH5_datatype 0x85
#define modbus_sensor_Uart8_CH6_datatype 0x86
#define modbus_sensor_Uart8_CH7_datatype 0x87
#define modbus_sensor_Uart8_CH8_datatype 0x88
#define modbus_sensor_Uart8_CH9_datatype 0x89
#define modbus_sensor_Uart8_CH10_datatype 0x8A

// 串口9采集的数据类型
#define modbus_sensor_Uart9_CH1_datatype 0x91
#define modbus_sensor_Uart9_CH2_datatype 0x92
#define modbus_sensor_Uart9_CH3_datatype 0x93
#define modbus_sensor_Uart9_CH4_datatype 0x94
#define modbus_sensor_Uart9_CH5_datatype 0x95
#define modbus_sensor_Uart9_CH6_datatype 0x96
#define modbus_sensor_Uart9_CH7_datatype 0x97
#define modbus_sensor_Uart9_CH8_datatype 0x98
#define modbus_sensor_Uart9_CH9_datatype 0x99
#define modbus_sensor_Uart9_CH10_datatype 0x9A

// 串口10采集的数据类型
#define modbus_sensor_Usart10_CH1_datatype 0xA1
#define modbus_sensor_Usart10_CH2_datatype 0xA2
#define modbus_sensor_Usart10_CH3_datatype 0xA3
#define modbus_sensor_Usart10_CH4_datatype 0xA4
#define modbus_sensor_Usart10_CH5_datatype 0xA5
#define modbus_sensor_Usart10_CH6_datatype 0xA6
#define modbus_sensor_Usart10_CH7_datatype 0xA7
#define modbus_sensor_Usart10_CH8_datatype 0xA8
#define modbus_sensor_Usart10_CH9_datatype 0xA9
#define modbus_sensor_Usart10_CH10_datatype 0xAA

/*----------------------------------------------------*/
// USART2 Channels (CH1 to CH10)
#define modbus_Usart2_CH1_sDevid 0x100
#define modbus_Usart2_CH1_sAddressreg 0x101
#define modbus_Usart2_CH1_sRegnum 0x102

#define modbus_Usart2_CH2_sDevid 0x103
#define modbus_Usart2_CH2_sAddressreg 0x104
#define modbus_Usart2_CH2_sRegnum 0x105

#define modbus_Usart2_CH3_sDevid 0x106
#define modbus_Usart2_CH3_sAddressreg 0x107
#define modbus_Usart2_CH3_sRegnum 0x108

#define modbus_Usart2_CH4_sDevid 0x109
#define modbus_Usart2_CH4_sAddressreg 0x10A
#define modbus_Usart2_CH4_sRegnum 0x10B

#define modbus_Usart2_CH5_sDevid 0x10C
#define modbus_Usart2_CH5_sAddressreg 0x10D
#define modbus_Usart2_CH5_sRegnum 0x10E

#define modbus_Usart2_CH6_sDevid 0x10F
#define modbus_Usart2_CH6_sAddressreg 0x110
#define modbus_Usart2_CH6_sRegnum 0x111

#define modbus_Usart2_CH7_sDevid 0x112
#define modbus_Usart2_CH7_sAddressreg 0x113
#define modbus_Usart2_CH7_sRegnum 0x114

#define modbus_Usart2_CH8_sDevid 0x115
#define modbus_Usart2_CH8_sAddressreg 0x116
#define modbus_Usart2_CH8_sRegnum 0x117

#define modbus_Usart2_CH9_sDevid 0x118
#define modbus_Usart2_CH9_sAddressreg 0x119
#define modbus_Usart2_CH9_sRegnum 0x11A

#define modbus_Usart2_CH10_sDevid 0x11B
#define modbus_Usart2_CH10_sAddressreg 0x11C
#define modbus_Usart2_CH10_sRegnum 0x11D

// USART3 Channels (CH1 to CH10)
#define modbus_Usart3_CH1_sDevid 0x11E
#define modbus_Usart3_CH1_sAddressreg 0x11F
#define modbus_Usart3_CH1_sRegnum 0x120

#define modbus_Usart3_CH2_sDevid 0x121
#define modbus_Usart3_CH2_sAddressreg 0x122
#define modbus_Usart3_CH2_sRegnum 0x123

#define modbus_Usart3_CH3_sDevid 0x124
#define modbus_Usart3_CH3_sAddressreg 0x125
#define modbus_Usart3_CH3_sRegnum 0x126

#define modbus_Usart3_CH4_sDevid 0x127
#define modbus_Usart3_CH4_sAddressreg 0x128
#define modbus_Usart3_CH4_sRegnum 0x129

#define modbus_Usart3_CH5_sDevid 0x12A
#define modbus_Usart3_CH5_sAddressreg 0x12B
#define modbus_Usart3_CH5_sRegnum 0x12C

#define modbus_Usart3_CH6_sDevid 0x12D
#define modbus_Usart3_CH6_sAddressreg 0x12E
#define modbus_Usart3_CH6_sRegnum 0x12F

#define modbus_Usart3_CH7_sDevid 0x130
#define modbus_Usart3_CH7_sAddressreg 0x131
#define modbus_Usart3_CH7_sRegnum 0x132

#define modbus_Usart3_CH8_sDevid 0x133
#define modbus_Usart3_CH8_sAddressreg 0x134
#define modbus_Usart3_CH8_sRegnum 0x135

#define modbus_Usart3_CH9_sDevid 0x136
#define modbus_Usart3_CH9_sAddressreg 0x137
#define modbus_Usart3_CH9_sRegnum 0x138

#define modbus_Usart3_CH10_sDevid 0x139
#define modbus_Usart3_CH10_sAddressreg 0x13A
#define modbus_Usart3_CH10_sRegnum 0x13B

// UART4 Channels (CH1 to CH10)
#define modbus_Uart4_CH1_sDevid 0x13C
#define modbus_Uart4_CH1_sAddressreg 0x13D
#define modbus_Uart4_CH1_sRegnum 0x13E

#define modbus_Uart4_CH2_sDevid 0x13F
#define modbus_Uart4_CH2_sAddressreg 0x140
#define modbus_Uart4_CH2_sRegnum 0x141

#define modbus_Uart4_CH3_sDevid 0x142
#define modbus_Uart4_CH3_sAddressreg 0x143
#define modbus_Uart4_CH3_sRegnum 0x144

#define modbus_Uart4_CH4_sDevid 0x145
#define modbus_Uart4_CH4_sAddressreg 0x146
#define modbus_Uart4_CH4_sRegnum 0x147

#define modbus_Uart4_CH5_sDevid 0x148
#define modbus_Uart4_CH5_sAddressreg 0x149
#define modbus_Uart4_CH5_sRegnum 0x14A

#define modbus_Uart4_CH6_sDevid 0x14B
#define modbus_Uart4_CH6_sAddressreg 0x14C
#define modbus_Uart4_CH6_sRegnum 0x14D

#define modbus_Uart4_CH7_sDevid 0x14E
#define modbus_Uart4_CH7_sAddressreg 0x14F
#define modbus_Uart4_CH7_sRegnum 0x150

#define modbus_Uart4_CH8_sDevid 0x151
#define modbus_Uart4_CH8_sAddressreg 0x152
#define modbus_Uart4_CH8_sRegnum 0x153

#define modbus_Uart4_CH9_sDevid 0x154
#define modbus_Uart4_CH9_sAddressreg 0x155
#define modbus_Uart4_CH9_sRegnum 0x156

#define modbus_Uart4_CH10_sDevid 0x157
#define modbus_Uart4_CH10_sAddressreg 0x158
#define modbus_Uart4_CH10_sRegnum 0x159

// UART5 Channels (CH1 to CH10)
#define modbus_Uart5_CH1_sDevid 0x15A
#define modbus_Uart5_CH1_sAddressreg 0x15B
#define modbus_Uart5_CH1_sRegnum 0x15C

#define modbus_Uart5_CH2_sDevid 0x15D
#define modbus_Uart5_CH2_sAddressreg 0x15E
#define modbus_Uart5_CH2_sRegnum 0x15F

#define modbus_Uart5_CH3_sDevid 0x160
#define modbus_Uart5_CH3_sAddressreg 0x161
#define modbus_Uart5_CH3_sRegnum 0x162

#define modbus_Uart5_CH4_sDevid 0x163
#define modbus_Uart5_CH4_sAddressreg 0x164
#define modbus_Uart5_CH4_sRegnum 0x165

#define modbus_Uart5_CH5_sDevid 0x166
#define modbus_Uart5_CH5_sAddressreg 0x167
#define modbus_Uart5_CH5_sRegnum 0x168

#define modbus_Uart5_CH6_sDevid 0x169
#define modbus_Uart5_CH6_sAddressreg 0x16A
#define modbus_Uart5_CH6_sRegnum 0x16B

#define modbus_Uart5_CH7_sDevid 0x16C
#define modbus_Uart5_CH7_sAddressreg 0x16D
#define modbus_Uart5_CH7_sRegnum 0x16E

#define modbus_Uart5_CH8_sDevid 0x16F
#define modbus_Uart5_CH8_sAddressreg 0x170
#define modbus_Uart5_CH8_sRegnum 0x171

#define modbus_Uart5_CH9_sDevid 0x172
#define modbus_Uart5_CH9_sAddressreg 0x173
#define modbus_Uart5_CH9_sRegnum 0x174

#define modbus_Uart5_CH10_sDevid 0x175
#define modbus_Uart5_CH10_sAddressreg 0x176
#define modbus_Uart5_CH10_sRegnum 0x177

// 串口6发送通道寄存器控制
#define modbus_Usart6_CH1_sDevid 0x178
#define modbus_Usart6_CH1_sAddressreg 0x179
#define modbus_Usart6_CH1_sRegnum 0x17A

#define modbus_Usart6_CH2_sDevid 0x17B
#define modbus_Usart6_CH2_sAddressreg 0x17C
#define modbus_Usart6_CH2_sRegnum 0x17D

#define modbus_Usart6_CH3_sDevid 0x17E
#define modbus_Usart6_CH3_sAddressreg 0x17F
#define modbus_Usart6_CH3_sRegnum 0x180

#define modbus_Usart6_CH4_sDevid 0x181
#define modbus_Usart6_CH4_sAddressreg 0x182
#define modbus_Usart6_CH4_sRegnum 0x183

#define modbus_Usart6_CH5_sDevid 0x184
#define modbus_Usart6_CH5_sAddressreg 0x185
#define modbus_Usart6_CH5_sRegnum 0x186

#define modbus_Usart6_CH6_sDevid 0x187
#define modbus_Usart6_CH6_sAddressreg 0x188
#define modbus_Usart6_CH6_sRegnum 0x189

#define modbus_Usart6_CH7_sDevid 0x18A
#define modbus_Usart6_CH7_sAddressreg 0x18B
#define modbus_Usart6_CH7_sRegnum 0x18C

#define modbus_Usart6_CH8_sDevid 0x18D
#define modbus_Usart6_CH8_sAddressreg 0x18E
#define modbus_Usart6_CH8_sRegnum 0x18F

#define modbus_Usart6_CH9_sDevid 0x190
#define modbus_Usart6_CH9_sAddressreg 0x191
#define modbus_Usart6_CH9_sRegnum 0x192

#define modbus_Usart6_CH10_sDevid 0x193
#define modbus_Usart6_CH10_sAddressreg 0x194
#define modbus_Usart6_CH10_sRegnum 0x195

// 串口7发送通道寄存器控制
#define modbus_Uart7_CH1_sDevid 0x196
#define modbus_Uart7_CH1_sAddressreg 0x197
#define modbus_Uart7_CH1_sRegnum 0x198

#define modbus_Uart7_CH2_sDevid 0x199
#define modbus_Uart7_CH2_sAddressreg 0x19A
#define modbus_Uart7_CH2_sRegnum 0x19B

#define modbus_Uart7_CH3_sDevid 0x19C
#define modbus_Uart7_CH3_sAddressreg 0x19D
#define modbus_Uart7_CH3_sRegnum 0x19E

#define modbus_Uart7_CH4_sDevid 0x19F
#define modbus_Uart7_CH4_sAddressreg 0x1A0
#define modbus_Uart7_CH4_sRegnum 0x1A1

#define modbus_Uart7_CH5_sDevid 0x1A2
#define modbus_Uart7_CH5_sAddressreg 0x1A3
#define modbus_Uart7_CH5_sRegnum 0x1A4

#define modbus_Uart7_CH6_sDevid 0x1A5
#define modbus_Uart7_CH6_sAddressreg 0x1A6
#define modbus_Uart7_CH6_sRegnum 0x1A7

#define modbus_Uart7_CH7_sDevid 0x1A8
#define modbus_Uart7_CH7_sAddressreg 0x1A9
#define modbus_Uart7_CH7_sRegnum 0x1AA

#define modbus_Uart7_CH8_sDevid 0x1AB
#define modbus_Uart7_CH8_sAddressreg 0x1AC
#define modbus_Uart7_CH8_sRegnum 0x1AD

#define modbus_Uart7_CH9_sDevid 0x1AE
#define modbus_Uart7_CH9_sAddressreg 0x1AF
#define modbus_Uart7_CH9_sRegnum 0x1B0

#define modbus_Uart7_CH10_sDevid 0x1B1
#define modbus_Uart7_CH10_sAddressreg 0x1B2
#define modbus_Uart7_CH10_sRegnum 0x1B3

// 串口8发送通道寄存器控制
#define modbus_Uart8_CH1_sDevid 0x1B4
#define modbus_Uart8_CH1_sAddressreg 0x1B5
#define modbus_Uart8_CH1_sRegnum 0x1B6

#define modbus_Uart8_CH2_sDevid 0x1B7
#define modbus_Uart8_CH2_sAddressreg 0x1B8
#define modbus_Uart8_CH2_sRegnum 0x1B9

#define modbus_Uart8_CH3_sDevid 0x1BA
#define modbus_Uart8_CH3_sAddressreg 0x1BB
#define modbus_Uart8_CH3_sRegnum 0x1BC

#define modbus_Uart8_CH4_sDevid 0x1BD
#define modbus_Uart8_CH4_sAddressreg 0x1BE
#define modbus_Uart8_CH4_sRegnum 0x1BF

#define modbus_Uart8_CH5_sDevid 0x1C0
#define modbus_Uart8_CH5_sAddressreg 0x1C1
#define modbus_Uart8_CH5_sRegnum 0x1C2

#define modbus_Uart8_CH6_sDevid 0x1C3
#define modbus_Uart8_CH6_sAddressreg 0x1C4
#define modbus_Uart8_CH6_sRegnum 0x1C5

#define modbus_Uart8_CH7_sDevid 0x1C6
#define modbus_Uart8_CH7_sAddressreg 0x1C7
#define modbus_Uart8_CH7_sRegnum 0x1C8

#define modbus_Uart8_CH8_sDevid 0x1C9
#define modbus_Uart8_CH8_sAddressreg 0x1CA
#define modbus_Uart8_CH8_sRegnum 0x1CB

#define modbus_Uart8_CH9_sDevid 0x1CC
#define modbus_Uart8_CH9_sAddressreg 0x1CD
#define modbus_Uart8_CH9_sRegnum 0x1CE

#define modbus_Uart8_CH10_sDevid 0x1CF
#define modbus_Uart8_CH10_sAddressreg 0x1D0
#define modbus_Uart8_CH10_sRegnum 0x1D1

// 串口9发送通道寄存器控制
#define modbus_Uart9_CH1_sDevid 0x1D2
#define modbus_Uart9_CH1_sAddressreg 0x1D3
#define modbus_Uart9_CH1_sRegnum 0x1D4

#define modbus_Uart9_CH2_sDevid 0x1D5
#define modbus_Uart9_CH2_sAddressreg 0x1D6
#define modbus_Uart9_CH2_sRegnum 0x1D7

#define modbus_Uart9_CH3_sDevid 0x1D8
#define modbus_Uart9_CH3_sAddressreg 0x1D9
#define modbus_Uart9_CH3_sRegnum 0x1DA

#define modbus_Uart9_CH4_sDevid 0x1DB
#define modbus_Uart9_CH4_sAddressreg 0x1DC
#define modbus_Uart9_CH4_sRegnum 0x1DD

#define modbus_Uart9_CH5_sDevid 0x1DE
#define modbus_Uart9_CH5_sAddressreg 0x1DF
#define modbus_Uart9_CH5_sRegnum 0x1E0

#define modbus_Uart9_CH6_sDevid 0x1E1
#define modbus_Uart9_CH6_sAddressreg 0x1E2
#define modbus_Uart9_CH6_sRegnum 0x1E3

#define modbus_Uart9_CH7_sDevid 0x1E4
#define modbus_Uart9_CH7_sAddressreg 0x1E5
#define modbus_Uart9_CH7_sRegnum 0x1E6

#define modbus_Uart9_CH8_sDevid 0x1E7
#define modbus_Uart9_CH8_sAddressreg 0x1E8
#define modbus_Uart9_CH8_sRegnum 0x1E9

#define modbus_Uart9_CH9_sDevid 0x1EA
#define modbus_Uart9_CH9_sAddressreg 0x1EB
#define modbus_Uart9_CH9_sRegnum 0x1EC

#define modbus_Uart9_CH10_sDevid 0x1ED
#define modbus_Uart9_CH10_sAddressreg 0x1EE
#define modbus_Uart9_CH10_sRegnum 0x1EF

// 串口10发送通道寄存器控制
#define modbus_Usart10_CH1_sDevid 0x1F0
#define modbus_Usart10_CH1_sAddressreg 0x1F1
#define modbus_Usart10_CH1_sRegnum 0x1F2

#define modbus_Usart10_CH2_sDevid 0x1F3
#define modbus_Usart10_CH2_sAddressreg 0x1F4
#define modbus_Usart10_CH2_sRegnum 0x1F5

#define modbus_Usart10_CH3_sDevid 0x1F6
#define modbus_Usart10_CH3_sAddressreg 0x1F7
#define modbus_Usart10_CH3_sRegnum 0x1F8

#define modbus_Usart10_CH4_sDevid 0x1F9
#define modbus_Usart10_CH4_sAddressreg 0x1FA
#define modbus_Usart10_CH4_sRegnum 0x1FB

#define modbus_Usart10_CH5_sDevid 0x1FC
#define modbus_Usart10_CH5_sAddressreg 0x1FD
#define modbus_Usart10_CH5_sRegnum 0x1FE

#define modbus_Usart10_CH6_sDevid 0x1FF
#define modbus_Usart10_CH6_sAddressreg 0x200
#define modbus_Usart10_CH6_sRegnum 0x201

#define modbus_Usart10_CH7_sDevid 0x202
#define modbus_Usart10_CH7_sAddressreg 0x203
#define modbus_Usart10_CH7_sRegnum 0x204

#define modbus_Usart10_CH8_sDevid 0x205
#define modbus_Usart10_CH8_sAddressreg 0x206
#define modbus_Usart10_CH8_sRegnum 0x207

#define modbus_Usart10_CH9_sDevid 0x208
#define modbus_Usart10_CH9_sAddressreg 0x209
#define modbus_Usart10_CH9_sRegnum 0x20A

#define modbus_Usart10_CH10_sDevid 0x20B
#define modbus_Usart10_CH10_sAddressreg 0x20C
#define modbus_Usart10_CH10_sRegnum 0x20D

/*----------------------------------------------------*/
//串口2读取数据保存寄存器配置
#define modbus_Usart2_CH1_read_addres 0x300
#define modbus_Usart2_CH2_read_addres 0x302
#define modbus_Usart2_CH3_read_addres 0x304
#define modbus_Usart2_CH4_read_addres 0x306
#define modbus_Usart2_CH5_read_addres 0x308
#define modbus_Usart2_CH6_read_addres 0x30A
#define modbus_Usart2_CH7_read_addres 0x30C
#define modbus_Usart2_CH8_read_addres 0x30E
#define modbus_Usart2_CH9_read_addres 0x310
#define modbus_Usart2_CH10_read_addres 0x312

// 串口3读取数据保存寄存器配置
#define modbus_Usart3_CH1_read_addres 0x314
#define modbus_Usart3_CH2_read_addres 0x316
#define modbus_Usart3_CH3_read_addres 0x318
#define modbus_Usart3_CH4_read_addres 0x31A
#define modbus_Usart3_CH5_read_addres 0x31C
#define modbus_Usart3_CH6_read_addres 0x31E
#define modbus_Usart3_CH7_read_addres 0x320
#define modbus_Usart3_CH8_read_addres 0x322
#define modbus_Usart3_CH9_read_addres 0x324
#define modbus_Usart3_CH10_read_addres 0x326

// 串口4读取数据保存寄存器配置
#define modbus_Uart4_CH1_read_addres 0x328
#define modbus_Uart4_CH2_read_addres 0x32A
#define modbus_Uart4_CH3_read_addres 0x32C
#define modbus_Uart4_CH4_read_addres 0x32E
#define modbus_Uart4_CH5_read_addres 0x330
#define modbus_Uart4_CH6_read_addres 0x332
#define modbus_Uart4_CH7_read_addres 0x334
#define modbus_Uart4_CH8_read_addres 0x336
#define modbus_Uart4_CH9_read_addres 0x338
#define modbus_Uart4_CH10_read_addres 0x33A

// 串口5读取数据保存寄存器配置
#define modbus_Uart5_CH1_read_addres 0x33C
#define modbus_Uart5_CH2_read_addres 0x33E
#define modbus_Uart5_CH3_read_addres 0x340
#define modbus_Uart5_CH4_read_addres 0x342
#define modbus_Uart5_CH5_read_addres 0x344
#define modbus_Uart5_CH6_read_addres 0x346
#define modbus_Uart5_CH7_read_addres 0x348
#define modbus_Uart5_CH8_read_addres 0x34A
#define modbus_Uart5_CH9_read_addres 0x34C
#define modbus_Uart5_CH10_read_addres 0x34E

// 串口6读取数据保存寄存器配置
#define modbus_Usart6_CH1_read_addres 0x350
#define modbus_Usart6_CH2_read_addres 0x352
#define modbus_Usart6_CH3_read_addres 0x354
#define modbus_Usart6_CH4_read_addres 0x356
#define modbus_Usart6_CH5_read_addres 0x358
#define modbus_Usart6_CH6_read_addres 0x35A
#define modbus_Usart6_CH7_read_addres 0x35C
#define modbus_Usart6_CH8_read_addres 0x35E
#define modbus_Usart6_CH9_read_addres 0x360
#define modbus_Usart6_CH10_read_addres 0x362

// 串口7读取数据保存寄存器配置
#define modbus_Uart7_CH1_read_addres 0x364
#define modbus_Uart7_CH2_read_addres 0x366
#define modbus_Uart7_CH3_read_addres 0x368
#define modbus_Uart7_CH4_read_addres 0x36A
#define modbus_Uart7_CH5_read_addres 0x36C
#define modbus_Uart7_CH6_read_addres 0x36E
#define modbus_Uart7_CH7_read_addres 0x370
#define modbus_Uart7_CH8_read_addres 0x372
#define modbus_Uart7_CH9_read_addres 0x374
#define modbus_Uart7_CH10_read_addres 0x376

// 串口8读取数据保存寄存器配置
#define modbus_Uart8_CH1_read_addres 0x378
#define modbus_Uart8_CH2_read_addres 0x37A
#define modbus_Uart8_CH3_read_addres 0x37C
#define modbus_Uart8_CH4_read_addres 0x37E
#define modbus_Uart8_CH5_read_addres 0x380
#define modbus_Uart8_CH6_read_addres 0x382
#define modbus_Uart8_CH7_read_addres 0x384
#define modbus_Uart8_CH8_read_addres 0x386
#define modbus_Uart8_CH9_read_addres 0x388
#define modbus_Uart8_CH10_read_addres 0x38A

// 串口9读取数据保存寄存器配置
#define modbus_Uart9_CH1_read_addres 0x38C
#define modbus_Uart9_CH2_read_addres 0x38E
#define modbus_Uart9_CH3_read_addres 0x390
#define modbus_Uart9_CH4_read_addres 0x392
#define modbus_Uart9_CH5_read_addres 0x394
#define modbus_Uart9_CH6_read_addres 0x396
#define modbus_Uart9_CH7_read_addres 0x398
#define modbus_Uart9_CH8_read_addres 0x39A
#define modbus_Uart9_CH9_read_addres 0x39C
#define modbus_Uart9_CH10_read_addres 0x39E

// 串口10读取数据保存寄存器配置
#define modbus_Usart10_CH1_read_addres 0x3A0
#define modbus_Usart10_CH2_read_addres 0x3A2
#define modbus_Usart10_CH3_read_addres 0x3A4
#define modbus_Usart10_CH4_read_addres 0x3A6
#define modbus_Usart10_CH5_read_addres 0x3A8
#define modbus_Usart10_CH6_read_addres 0x3AA
#define modbus_Usart10_CH7_read_addres 0x3AC
#define modbus_Usart10_CH8_read_addres 0x3AE
#define modbus_Usart10_CH9_read_addres 0x3B0
#define modbus_Usart10_CH10_read_addres 0x3B2

//JDQ1、JDQ2配置
#define modbus_JDQ1_status 0x3C0//继电器1，0关闭，1导通
#define modbus_JDQ2_status 0x3C1//继电器2，0关闭，1导通
#define modbus_JDQ1_opentime 0x3C2//继电器1//分钟
#define modbus_JDQ2_opentime 0x3C3//继电器2//分钟
#define modbus_JDQ1_closetime 0x3C4//继电器1//分钟
#define modbus_JDQ2_closetime 0x3C5//继电器2//分钟

#define modbus_vin_adc_value 0x3D1//供电电压采集
#define modbus_vin_adc_value_offset1 0x3D2//供电电压采集偏置
#define modbus_vin_adc_value_offset2 0x3D2//供电电压采集偏置

//RTC时间校准 uint32 大小端
#define modbus_RTC_Calculate1 0x3E1//大端
#define modbus_RTC_Calculate2 0x3E2//小端

unsigned short  CRC16(unsigned char *ptr, unsigned char len);
void Usart1_Send(uint8_t* str, uint16_t cnt);
void Usart2_Send(uint8_t* str, uint16_t cnt);
void Usart3_Send(uint8_t* str, uint16_t cnt);
void Uart4_Send(uint8_t* str, uint16_t cnt);
void Uart5_Send(uint8_t* str, uint16_t cnt);
void Usart6_Send(uint8_t* str, uint16_t cnt);
void Uart7_Send(uint8_t* str, uint16_t cnt);
void Uart8_Send(uint8_t* str, uint16_t cnt);
void Uart9_Send(uint8_t* str, uint16_t cnt);
void Usart10_Send(uint8_t* str, uint16_t cnt);

void ModbusConfig_Usart1(void);//4G网关
void Modbus_Function_6(void);
void Modbus_Function_3(void);
void deviceSensorRead_Usart2(void); //串口2设备任务
void deviceSensorRead_Usart3(void); //串口3设备任务
void deviceSensorRead_Uart4(void);  //串口4设备任务
void deviceSensorRead_Uart5(void);  //串口5设备任务
void deviceSensorRead_Usart6(void); //串口6设备任务
void deviceSensorRead_Uart7(void);  //串口7设备任务
void deviceSensorRead_Uart8(void);  //串口8设备任务
void deviceSensorRead_Uart9(void);  //串口9设备任务
void deviceSensorRead_Usart10(void);//串口10设备任务

#endif
